﻿using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;

namespace Colorful.Furniture.EnterpriseManagement;

/// <summary>
///  部门
/// </summary>
[Table(Name = "em_department")]
public class Department
{
    /// <summary>
    ///  id
    /// </summary>
    [Column(Name = "id")]
    public virtual Guid Id { get; set; }

    /// <summary>
    ///  部门id
    /// </summary>
    [Column(Name = "depart_id")]
    public virtual long DepartId { get; set; }

    /// <summary>
    ///  部门名称，代开发自建应用需要管理员授权才返回；此字段从2019年12月30日起，对新创建第三方应用不再返回，2020年6月30日起，对所有历史第三方应用不再返回name，返回的name字段使用id代替，后续第三方仅通讯录应用可获取，未返回名称的情况需要通过通讯录展示组件来展示部门名称
    /// </summary>
    [Column(Name = "name", StringLength = 50)]
    public string Name { get; set; }

    /// <summary>
    ///  英文名称，此字段从2019年12月30日起，对新创建第三方应用不再返回，2020年6月30日起，对所有历史第三方应用不再返回该字段
    /// </summary>
    [Column(Name = "name_en", StringLength = 50)]
    public string NameEn { get; set; }

    /// <summary>
    ///  父部门id。根部门为1
    /// </summary>
    [Column(Name = "parent_depart_id")]
    public virtual long ParentDepartId { get; set; }

    /// <summary>
    ///  层级，格式：,1,29,
    /// </summary>
    [Column(Name = "class_id", StringLength = 2000)]
    public string ClassId { get; set; }

    /// <summary>
    ///  部门负责人，json存放
    /// </summary>
    [Column(Name = "department_leader", StringLength = 4000)]
    public string DepartmentLeader { get; set; }

    /// <summary>
    ///  排序字段：值越大越靠前
    /// </summary>
    [Column(Name = "sort")]
    public long Sort { get; set; }

    /// <summary>
    ///  创建时间
    /// </summary>
    [Column(Name = "add_time", CanUpdate = false)]
    public DateTime AddTime { get; set; }

    
}

/// <summary>
///  部门查询实体
/// </summary>
[Table(Name = "em_department")]
public class DepartmentSearch : Department
{
    /// <summary>
    ///  编码
    /// </summary>
    [Column(IsPrimary = false, Name = "id")]
    public override Guid Id { get; set; }

    /// <summary>
    ///  部门id
    /// </summary>
    [Column(IsPrimary = true, Name = "depart_id")]
    public override long DepartId { get; set; }

    /// <summary>
    ///  父级
    /// </summary>
    public DepartmentSearch ParentDepart { get; set; }

    /// <summary>
    ///  子级
    /// </summary>
    public List<DepartmentSearch> Children { get; set; }
}